from sklearn.feature_extraction.text import TfidfVectorizer

corpus = ['second third document.','second second document.']

vectorizer = TfidfVectorizer()

X = vectorizer.fit_transform(corpus)

print(X.toarray())
print(vectorizer.get_feature_names())

test = [' a first document','thid ac dc.']

print(vectorizer.transform(test).toarray())
print(vectorizer.get_feature_names())